<?php

// Register widgetized areas
if ( function_exists('register_sidebar') ) {

	//register_sidebars(1,array('name' => 'Front Page Banner Left','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h3><span>','after_title' => '</span></h3>'));
	//register_sidebars(1,array('name' => 'Front Page Banner Right','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h3><span>','after_title' => '</span></h3>'));
	//register_sidebars(1,array('name' => 'Front Page Banner Right Sub col-1','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h3><span>','after_title' => '</span></h3>'));
	//register_sidebars(1,array('name' => 'Front Page Banner Right Sub col-2','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h3><span>','after_title' => '</span></h3>'));
	register_sidebars(1,array('name' => 'Footer Above Section','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h3><span>','after_title' => '</span></h3>'));
	register_sidebars(1,array('name' => 'Footer 1','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h3><span>','after_title' => '</span></h3>'));
	register_sidebars(1,array('name' => 'Footer 2','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h3><span>','after_title' => '</span></h3>'));
	register_sidebars(1,array('name' => 'Footer 3','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h3><span>','after_title' => '</span></h3>'));
	register_sidebars(1,array('name' => 'Footer 4','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h3><span>','after_title' => '</span></h3>'));
	register_sidebars(1,array('name' => 'Footer 5','before_widget' => '<div class="widget">','after_widget' => '</div>','before_title' => '<h3><span>','after_title' => '</span></h3>'));
}
	

 // =============================== Advt Widget ======================================
class advtwidget extends WP_Widget {
	function advtwidget() {
	//Constructor
		$widget_ops = array('classname' => 'widget Advt', 'description' => 'Front Page Text Widget' );		
		$this->WP_Widget('widget_advtwidget', 'PT &rarr; Advt', $widget_ops);
	}
	function widget($args, $instance) {
	// prints the widget
		extract($args, EXTR_SKIP);
		$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
		$advt1 = empty($instance['advt1']) ? '' : apply_filters('widget_advt1', $instance['advt1']);
		$advt_link1 = empty($instance['advt_link1']) ? '' : apply_filters('widget_advt_link1', $instance['advt_link1']);
		$advt2 = empty($instance['advt2']) ? '' : apply_filters('widget_advt2', $instance['advt2']);
		$advt_link2 = empty($instance['advt_link2']) ? '' : apply_filters('widget_advt_link2', $instance['advt_link2']);
		 ?>						

 
      		<!--<h3><?php // echo $title; ?> </h3>-->
         
      <div class="front_advt">
        <?php if ( $advt1 <> "" ) { ?>	 <?php echo $advt1; ?> <?php } ?>
      </div>
              
	<?php
	}
	function update($new_instance, $old_instance) {
	//save the widget
		$instance = $old_instance;		
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['advt1'] = ($new_instance['advt1']);
		$instance['advt_link1'] = ($new_instance['advt_link1']);
		$instance['advt2'] = ($new_instance['advt2']);
		$instance['advt_link2'] = ($new_instance['advt_link2']);
		return $instance;
	}
	function form($instance) {
	//widgetform in backend
		$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'advt1' => '', 'advt_link1' => '', 'advt2' => '', 'advt_link2' => '' ) );		
		$title = strip_tags($instance['title']);
		$advt1 = ($instance['advt1']);
		$advt_link1 = ($instance['advt_link1']);
		$advt2 = ($instance['advt2']);
		$advt_link2 = ($instance['advt_link2']);			
?>
<!--<p><label for="<?php // echo $this->get_field_id('title'); ?>">Widget Title: <input class="widefat" id="<?php // echo $this->get_field_id('title'); ?>" name="<?php // echo $this->get_field_name('title'); ?>" type="text" value="<?php // echo attribute_escape($title); ?>" /></label></p>-->
  <p><label for="<?php echo $this->get_field_id('advt1'); ?>">Advtisment Here (ex.&lt;a href="http://templatic.com"&gt; &lt;img src="http://templatic.com/banner.png" alt="" /&gt; &lt;/a&gt; or google ads ) <textarea class="widefat" rows="6" cols="20" id="<?php echo $this->get_field_id('advt1'); ?>" name="<?php echo $this->get_field_name('advt1'); ?>"><?php echo attribute_escape($advt1); ?></textarea></label></p>
<?php
	}}
register_widget('advtwidget');



// =============================== Shopping Cart info Widget (particular category) ======================================
class shopping_cart_info2 extends WP_Widget {
	function shopping_cart_info2() {
	//Constructor
		$widget_ops = array('classname' => 'widget shopping_cart_info2', 'description' => __('Shopping Cart Information') );
		$this->WP_Widget('shopping_cart_info2', __('PT &rarr; Shopping Cart Info'), $widget_ops);
	}

	function widget($args, $instance) {
	// prints the widget
		global $General;
		extract($args, EXTR_SKIP);
		echo $before_widget;
 		$title = empty($instance['title']) ? '' : apply_filters('widget_category', $instance['title']);
		if($before_title=='' || $after_title=='')
		{
			$before_title=='<h4>';
			$after_title=='</h4>';
		}
		global $Cart,$General;
		$itemsInCartCount = $Cart->cartCount();
		$cartAmount = $Cart->getCartAmt();
		$ship_limit = $General->get_ship_limit();
		$cart_amt = $General->get_payable_amount();//$General->get_amount_format($cartAmount);
		$cart_amt1 = $General->get_amount_format($cartAmount);
		$cartInfo = $Cart->getcartInfo();
		if($cart_amt){ $cart_amt = "$cart_amt";}
		?>
        
        <div class="header_cart">
        <span class="title_small"><?php if($itemsInCartCount== "0") { _e('Cart is empty'); }else {_e('Cart');} ?></span>
			<?php if($itemsInCartCount!="0"){ ?>
             <p>
             <a href="<?php echo site_url('/?ptype=cart'); ?>" class="item_lnk">
	             <strong>
		             <span id="cart_information_span1">
					 	<?php echo $itemsInCartCount;?>
		             </span>
                     <?php if($itemsInCartCount== "1"){ _e('item'); }else{ _e('items');} ?>
	             </strong>
             </a>
            </p>
            <?php } ?>
           <?php 
		   if($cartInfo){
			   ?>
               <div class="dropdown">
           			<div class="wrap-element">
		               <ul class="cartinfo">
                        <li><p class="pdt">Product</p><p class="amt">Price</p><p class="qty">Quantity</p></li>
		               <?php 
					   for($i=0;$i<count($cartInfo); $i++){
						   ?>
					   <li><p class="pdt"><?php echo $cartInfo[$i][product_name] ?></p><p class="amt"><?php echo $cartInfo[$i][product_gross_price] ?></p><p class="qty"><?php echo $cartInfo[$i][product_qty] ?></p></li>
		               <?php
				   }
				   ?>
                   <?php if($ship_limit[0] > 0){ ?>
                    <li><p>+ Shipping Charges (<a href="#" title="<?php print $ship_limit[1]; ?>">?</a>)</p><p class="amt"><?php print $ship_limit[0]; ?></p>
					<?php }?>
		           </ul>
		           <div class="drop-total">
		           <div class="fl">
		            <a href="<?php echo site_url('/?ptype=cart'); ?>" class="btn_checkout"> <span id="cart_information_span11"><strong><?php _e(CHECKOUT_TEXT);?></strong></span></a>
		            </div>
		          	<div class="fr">
                    <p><?php _e('Total')?>: <?php echo $cart_amt; ?></p></div>
		           </div>
               </div>
           </div>
            <?php
		   }
		   ?>
          </div>
		  
      	<?php
		echo $after_widget;
	}

	function update($new_instance, $old_instance) {
	//save the widget
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		return $instance;

	}

	function form($instance) {
	//widgetform in backend
		$instance = wp_parse_args( (array) $instance, array( 'title' => 'Shopping Cart' ) );
		$title = strip_tags($instance['title']);
?>
<p>
  <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title');?> :
  <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" />
  </label>
</p>
<?php
	}

}
register_widget('shopping_cart_info2');


// =============================== Latest Posts Widget (particular category) ======================================
class home_slider extends WP_Widget {
	function home_slider() {
	//Constructor
		$widget_ops = array('classname' => 'widget home slider', 'description' => __('List of latest posts in particular category') );
		$this->WP_Widget('widget_home_slider', __('PT &rarr; Home Slider'), $widget_ops);
	}

	function widget($args, $instance) {
	// prints the widget

		extract($args, EXTR_SKIP);
		echo $before_widget;
 		$category = empty($instance['category']) ? '&nbsp;' : apply_filters('widget_category', $instance['category']);
		$post_number = empty($instance['post_number']) ? '&nbsp;' : apply_filters('widget_post_number', $instance['post_number']);
		$post_link = empty($instance['post_link']) ? '&nbsp;' : apply_filters('widget_post_link', $instance['post_link']);
		$auto_rotate = empty($instance['auto_rotate']) ? 'Yes' : apply_filters('widget_auto_rotate', $instance['auto_rotate']);
		$speed =  empty($instance['speed']) ? '5000' : apply_filters('widget_speed', $instance['speed']);
		$image_width =  empty($instance['image_width']) ? '420' : apply_filters('widget_image_width', $instance['image_width']);
		$image_height =  empty($instance['image_height']) ? '' : apply_filters('widget_image_height', $instance['image_height']);
		$content_lenght =  empty($instance['content_lenght']) ? '700' : apply_filters('widget_content_lenght', $instance['content_lenght']);
		if($auto_rotate=='No'){$speed='100000';}
		
		?>
        <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/library/js/jquery.easing.1.3.js"></script>
		<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/library/js/slider.js"></script>
		<?php
		echo "<script type='text/javascript'>
			var autoSlider_var = '".$auto_rotate."';
			var autoSlideInterval_var = '".$speed."';
			</script>";

		if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
		echo '
     <div class="coda-slider-wrapper"><div class="coda-slider preload" id="coda-slider-1">';

		        ?>

<?php 
			        global $post;
			        $latest_menus = get_posts('numberposts='.$post_number.'postlink='.$post_link.'&category='.$category.'');
                    foreach($latest_menus as $post) :
                    setup_postdata($post);
			    ?>
<?php $button = get_post_meta($post->ID, 'button', $single = true);	?>
<?php $button_url = get_post_meta($post->ID, 'button_url', $single = true);	?>



<div class="panel">
  <div class="panel-wrapper">
    <?php
		global $Product;
		$product_image_arr = $Product->get_product_image($post,'large');
		if($product_image_arr && $product_image_arr[0])
		{
			$imagepath = $product_image_arr[0];
		}
		  if($imagepath)
		  {
			  global $thumb_url;
		  ?>
    <a href="<?php the_permalink() ?>"><img src="<?php echo $imagepath; ?>" alt=""  /></a>
    <?php  } ?>
    
    <div class="rate_strip">
            	<span> <?php if(get_option('currencysym') == '')
			{
				echo '$';
			}else
			{
				echo get_option('currencysym');
			} ?> </span>
                
                
                
                <span class="price"> <?php
			global $General,$Product;
			if($Product->get_product_price_sale($post->ID)>0)
			{
			?>
			
			<?php echo $General->get_amount_format($Product->get_product_price_sale($post->ID)); 
			}else
			{
				echo $General->get_amount_format($Product->get_product_price_only($post->ID)); 
			}
			?>
                
                </span>
                <div class="fl">
                	<h3><a class="widget-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </h3>
                	<p><?php the_category(" &amp;"); ?></p>
                </div>
            </div>
                
                
    <?php /*?><h1><a class="widget-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </h1>
    <p class="featured-excerpt"><?php echo bm_better_excerpt($content_lenght, ' ... '); ?> </p>
    <div class="button"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php _e('View Details');?></a> </div><?php */?>
  </div>
</div>
<?php endforeach; ?>
<?php

	    echo '</div>
		     </div>
  ';

		echo $after_widget;
	}

	function update($new_instance, $old_instance) {
	//save the widget
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['category'] = strip_tags($new_instance['category']);
		$instance['post_number'] = strip_tags($new_instance['post_number']);
		$instance['post_link'] = strip_tags($new_instance['post_link']);
		$instance['auto_rotate'] = strip_tags($new_instance['auto_rotate']);
		$instance['speed'] = strip_tags($new_instance['speed']);
		$instance['image_width'] = strip_tags($new_instance['image_width']);
		$instance['image_height'] = strip_tags($new_instance['image_height']);
		$instance['content_lenght'] = strip_tags($new_instance['content_lenght']);
		return $instance;

	}

	function form($instance) {
	//widgetform in backend
		$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'category' => '', 'post_number' => '','auto_rotate'=>'Yes','speed'=>'5000','image_width'=>'420','image_height'=>'460','content_lenght'=>'700' ) );
		$title = strip_tags($instance['title']);
		$category = strip_tags($instance['category']);
		$post_number = strip_tags($instance['post_number']);
		$post_link = strip_tags($instance['post_link']);
		$auto_rotate = strip_tags($instance['auto_rotate']);
		$speed = strip_tags($instance['speed']);
		$image_width = strip_tags($instance['image_width']);
		$image_height = strip_tags($instance['image_height']);
		$content_lenght = strip_tags($instance['content_lenght']);
?>
<p>
  <label for="<?php echo $this->get_field_id('category'); ?>"><?php _e('Categories (<code>IDs</code> separated by commas):');?>
  <input class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>" type="text" value="<?php echo attribute_escape($category); ?>" />
  </label>
</p>
<p>
  <label for="<?php echo $this->get_field_id('post_number'); ?>"><?php _e('Number of posts:');?>
  <input class="widefat" id="<?php echo $this->get_field_id('post_number'); ?>" name="<?php echo $this->get_field_name('post_number'); ?>" type="text" value="<?php echo attribute_escape($post_number); ?>" />
  </label>
</p>
<p>
  <label for="<?php echo $this->get_field_id('auto_rotate'); ?>"><?php _e('Set slider auto rotation:');?>
  <select id="<?php echo $this->get_field_id('auto_rotate'); ?>" name="<?php echo $this->get_field_name('auto_rotate'); ?>" style="width:50%;">
  <option <?php if(attribute_escape($auto_rotate)=='Yes'){ echo 'selected="selected"';}?>>Yes</option>
  <option <?php if(attribute_escape($auto_rotate)=='No'){ echo 'selected="selected"';}?>>No</option>
  </select>
  </label>
</p>
<p>
  <label for="<?php echo $this->get_field_id('speed'); ?>"><?php _e('Slider rotation speed(frame/milisecond):');?>
  <input class="widefat" id="<?php echo $this->get_field_id('speed'); ?>" name="<?php echo $this->get_field_name('speed'); ?>" type="text" value="<?php echo attribute_escape($speed); ?>" />
  </label>
</p>
<?php /*?><p>
  <label for="<?php echo $this->get_field_id('image_width'); ?>"><?php _e('Slider image Width in px <br />(Default is 420px):');?>
  <input class="widefat" id="<?php echo $this->get_field_id('image_width'); ?>" name="<?php echo $this->get_field_name('image_width'); ?>" type="text" value="<?php echo attribute_escape($image_width); ?>" />
  </label>
</p>
<p>
  <label for="<?php echo $this->get_field_id('image_height'); ?>"><?php _e('Slider image Height in px <br />(Default is 460px):');?>
  <input class="widefat" id="<?php echo $this->get_field_id('image_height'); ?>" name="<?php echo $this->get_field_name('image_height'); ?>" type="text" value="<?php echo attribute_escape($image_height); ?>" />
  </label>
</p><?php */?>
<p>
  <label for="<?php echo $this->get_field_id('content_lenght'); ?>"><?php _e('Slider content Length in characters:');?>
  <input class="widefat" id="<?php echo $this->get_field_id('content_lenght'); ?>" name="<?php echo $this->get_field_name('content_lenght'); ?>" type="text" value="<?php echo attribute_escape($content_lenght); ?>" />
  </label>
</p>
<?php
	}

}
register_widget('home_slider');


// =============================== Special Product  Widget (particular category) ======================================

class special_product extends WP_Widget {
	function special_product() {
	//Constructor
		$widget_ops = array('classname' => 'widget Special Product', 'description' => 'List of Special Product in particular category' );
		$this->WP_Widget('widget_special_product', 'PT &rarr; Special Product', $widget_ops);
	}

	function widget($args, $instance) {
	// prints the widget
		global $General,$Product;
		extract($args, EXTR_SKIP);
		echo $before_widget;
		$title = empty($instance['title']) ? 'Special Products' : apply_filters('widget_title', $instance['title']);
 		$category = empty($instance['category']) ? '&nbsp;' : apply_filters('widget_category', $instance['category']);
		$post_number = empty($instance['post_number']) ? '&nbsp;' : apply_filters('widget_post_number', $instance['post_number']);
		$post_link = empty($instance['post_link']) ? '&nbsp;' : apply_filters('widget_post_link', $instance['post_link']);
			?>
			 
			<?php 
			wp_reset_query();
			        global $post;
			        //$latest_menus = get_posts('numberposts='.$post_number.'postlink='.$post_link.'&category='.$category.'');
					//$featured_post = query_post( 'p=733&posts_per_page=1' );
					$post = get_post($category);
					//echo $featured_post->post_title;
                    if($post){
					//foreach($featured_post as $post) :
                    setup_postdata($post);
			    ?>
             
             <div class="top_latest"> 
             
            
            <?php
		global $Product;
		$product_image_arr = $Product->get_product_image($post,'thumb');
		if(has_post_thumbnail($post->ID)){
				 $product_image_arr =wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail');
		}
		
		if($product_image_arr[0])
		{
			$imagepath = $product_image_arr[0];
		}
		  if($imagepath)
		  {
			  global $thumb_url;
		  ?>
     <a href="<?php the_permalink() ?>" class="product_latest"><span class="spaceball"></span><img src="<?php echo $imagepath; ?>" alt=""  /></a> 
    <?php  } ?>
            
        <div class="latest_holder">
        <div class="sale_price">
                
                <span class="price_holder"> 
				<?php
			global $General,$Product;
			if($Product->get_product_price_sale($post->ID)>0)
			{
			?>
			
			<?php echo '<span class="left-curve special"></span><b>'. $General->get_amount_format($Product->get_product_price_sale($post->ID)).'</b>'.
			'<s>'.$General->get_amount_format($Product->get_product_price_only($post->ID)).'</s>';
			}else
			{
				echo '<p>'.$General->get_amount_format($Product->get_product_price_only($post->ID)).'</p><span class="left-curve"></span>'; 
			}
			?>
               </span> 
                </div>
                <div class="dealbanner">Deal of the Week</div>
                <div class="content">
                	<h3><a class="widget-title" href="<?php the_permalink(); ?>"><?php echo the_title(); ?></a> </h3>
                	
               
            </div>
        </div>
        </div>
        
	 
		 <?php }// endforeach; ?>
		<?php
        echo '';
	echo $after_widget;
}

	function update($new_instance, $old_instance) {
	//save the widget
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['category'] = strip_tags($new_instance['category']);
		$instance['post_number'] = strip_tags($new_instance['post_number']);
		$instance['post_link'] = strip_tags($new_instance['post_link']);
		return $instance;

	}

	function form($instance) {
	//widgetform in backend
		$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'category' => '', 'post_number' => '' ) );
		$title = strip_tags($instance['title']);
		$category = strip_tags($instance['category']);
		$post_number = strip_tags($instance['post_number']);
		$post_link = strip_tags($instance['post_link']);

?>
<p><label for="<?php echo $this->get_field_id('title'); ?>">Widget Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
<p>
  <label for="<?php echo $this->get_field_id('category'); ?>">Post ID:
    <input class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>" type="text" value="<?php echo attribute_escape($category); ?>" />
  </label>
</p>
<p style="display:none;">
  <label for="<?php echo $this->get_field_id('post_number'); ?>">Number of posts:
    <input class="widefat" id="<?php echo $this->get_field_id('post_number'); ?>" name="<?php echo $this->get_field_name('post_number'); ?>" type="text" value="<?php echo attribute_escape($post_number); ?>" />
  </label>
</p>
<?php
	}

}

register_widget('special_product');


// =============================== Latest news posts Widget (particular category) ======================================

class latest_post1 extends WP_Widget {
	function latest_post1() {
	//Constructor
		$widget_ops = array('classname' => 'widget Latest News', 'description' => 'List of latest posts in particular category' );
		$this->WP_Widget('latest_post1', 'PT &rarr; Latest News', $widget_ops);
	}

	function widget($args, $instance) {
	// prints the widget

		extract($args, EXTR_SKIP);
		echo $before_widget;
		$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
 		$category = empty($instance['category']) ? '&nbsp;' : apply_filters('widget_category', $instance['category']);
		$post_number = empty($instance['post_number']) ? '&nbsp;' : apply_filters('widget_post_number', $instance['post_number']);
		$post_link = empty($instance['post_link']) ? '&nbsp;' : apply_filters('widget_post_link', $instance['post_link']);

		// if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
		echo '';
		 ?>
         
          <?php if($title){?> 
				<h3><?php echo $title; ?></h3>			
				<?php }  ?>
          
          <div class="latestpost">
				<?php 
			        global $post;
			        $latest_menus = get_posts('numberposts='.$post_number.'postlink='.$post_link.'&category='.$category.'');
                    foreach($latest_menus as $post) :
                    setup_postdata($post);
			    ?>
                 <?php $post_images = bdw_get_images($post->ID,'large');?>
                 
                 
                 
                 
        	<div class="post_list">
            	<p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
                <cite>By <?php the_author_posts_link(); ?></cite>
            	<div class="date"> <?php the_time('jS F')  ?></div>
            </div>            
       
                 
            
                  
             
    
<?php endforeach; ?>
<?php

	    echo ' </div>';

		echo $after_widget;
	}

	function update($new_instance, $old_instance) {
	//save the widget
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['category'] = strip_tags($new_instance['category']);
		$instance['post_number'] = strip_tags($new_instance['post_number']);
		$instance['post_link'] = strip_tags($new_instance['post_link']);
		return $instance;

	}

	function form($instance) {
	//widgetform in backend
		$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'category' => '', 'post_number' => '' ) );
		$title = strip_tags($instance['title']);
		$category = strip_tags($instance['category']);
		$post_number = strip_tags($instance['post_number']);
		$post_link = strip_tags($instance['post_link']);

?>
<p>
  <label for="<?php echo $this->get_field_id('title'); ?>">Title:
    <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" />
  </label>
</p>
<p>
  <label for="<?php echo $this->get_field_id('category'); ?>">Categories (<code>IDs</code> separated by commas):
  <input class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>" type="text" value="<?php echo attribute_escape($category); ?>" />
  </label>
</p>
<p>
  <label for="<?php echo $this->get_field_id('post_number'); ?>">Number of posts:
  <input class="widefat" id="<?php echo $this->get_field_id('post_number'); ?>" name="<?php echo $this->get_field_name('post_number'); ?>" type="text" value="<?php echo attribute_escape($post_number); ?>" />
  </label>
</p>
<?php
	}

}

register_widget('latest_post1');


// =============================== Feedburner Subscribe widget ======================================
class subscribeWidget_blue extends WP_Widget {
	function subscribeWidget_blue() {
	//Constructor
		$widget_ops = array('classname' => 'widget Subscribe', 'description' => 'Subscribe' );		
		$this->WP_Widget('widget_subscribeWidget_blue', 'PT &rarr; Subscribe', $widget_ops);
	}
	function widget($args, $instance) {
	// prints the widget
		extract($args, EXTR_SKIP);
		$id = empty($instance['id']) ? '' : apply_filters('widget_id', $instance['id']);
		$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
		$text = empty($instance['text']) ? '' : apply_filters('widget_text', $instance['text']);
		$twitter = empty($instance['twitter']) ? '' : apply_filters('widget_twitter', $instance['twitter']);
		$facebook = empty($instance['facebook']) ? '' : apply_filters('widget_facebook', $instance['facebook']);
		$digg = empty($instance['digg']) ? '' : apply_filters('widget_digg', $instance['digg']);
		$myspace = empty($instance['myspace']) ? '' : apply_filters('widget_myspace', $instance['myspace']);
		$rss = empty($instance['rss']) ? '' : apply_filters('widget_rss', $instance['rss']);
?>
	
     
		 
	  <div class="subscribe clearfix">
    	<div class="subscribe_bg " >
         <?php if($title){?> 
      <h3><?php echo $title; ?> </h3>
       <?php } ?>
      
          	<?php if ( $text <> "" ) { ?>	 
         		 <p><?php echo $text; ?> </p>
            <?php } ?>
        
		<form class="subscribe_form"  action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow"  onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=<?php echo $id; ?>', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true">    
     <input type="text" class="text_bg" onfocus="if (this.value == '<?php _e('Your Email Address')?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('Your Email Address')?>';}" name="email" value="Your Email Address" />
     <input type="hidden" value="<?php echo $id; ?>" name="uri"/><input type="hidden" name="loc" value="en_US"/>
     <input class="subscribe_submit" type="submit" name="submit" value="Subscribe" /> 
     </form>
		  </div>  <!-- #end -->
        </div>   
          
          
          

<?php
	}
	function update($new_instance, $old_instance) {
	//save the widget
		$instance = $old_instance;		
		$instance['id'] = strip_tags($new_instance['id']);
		$instance['title'] = ($new_instance['title']);
		$instance['text'] = ($new_instance['text']);
		$instance['twitter'] = ($new_instance['twitter']);
		$instance['facebook'] = ($new_instance['facebook']);
		$instance['digg'] = ($new_instance['digg']);
		$instance['myspace'] = ($new_instance['myspace']);
		
		return $instance;
	}
	function form($instance) {
	//widgetform in backend
		$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'advt1' => '','text' => '','twitter' => '','facebook' => '','digg' => '','myspace' => '' ) );		
		$id = strip_tags($instance['id']);
		$title = strip_tags($instance['title']);
		$text = strip_tags($instance['text']);
		$twitter = strip_tags($instance['twitter']);
		$facebook = strip_tags($instance['facebook']);
		$digg = strip_tags($instance['digg']);
		$myspace = strip_tags($instance['myspace']);

 ?>
 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title');?>: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
 <p><label for="<?php echo $this->get_field_id('id'); ?>"><?php _e('Feedburner ID (ex :- templatic)');?>: <input class="widefat" id="<?php echo $this->get_field_id('id'); ?>" name="<?php echo $this->get_field_name('id'); ?>" type="text" value="<?php echo attribute_escape($id); ?>" /></label></p>
  <p><label for="<?php echo $this->get_field_id('text'); ?>"><?php _e('Short Description');?> <textarea class="widefat" rows="6" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo attribute_escape($text); ?></textarea></label></p>
<?php
	}}
register_widget('subscribeWidget_blue');


// =============================== Latest Products Widget ======================================
class latest_product_navi_widget extends WP_Widget {
	function latest_product_navi_widget() {
	//Constructor
		$widget_ops = array('classname' => 'widget latest_product_info', 'description' => __('Latest Products') );
		$this->WP_Widget('latest_product_info', __('PT &rarr; Latest Products'), $widget_ops);
	}

	function widget($args, $instance) {
	// prints the widget
		global $Cart,$General,$Product,$post;
		extract($args, EXTR_SKIP);
		echo $before_widget;
 		if($before_title=='' || $after_title=='')
		{
			$before_title=='<h4>';
			$after_title=='</h4>';
		}
		$category = empty($instance['category']) ? '' : apply_filters('widget_category', $instance['category']);
		$title = empty($instance['title']) ? __('Latest Products') : apply_filters('widget_title', $instance['title']);
		$display_prds_no = empty($instance['display_prds_no']) ? '16' : apply_filters('widget_display_prds_no', $instance['display_prds_no']);
		$list_type = empty($instance['display_prds_no']) ? 'Grid' : apply_filters('widget_display_prds_no', $instance['list_type']);
		$show_store_link = empty($instance['show_store_link']) ? '' : apply_filters('widget_show_store_link', $instance['show_store_link']);
		$link_url = empty($instance['link_url']) ? '' : apply_filters('widget_link_url', $instance['link_url']);
		//$image_width = empty($instance['image_width']) ? '170' : apply_filters('widget_image_width', $instance['image_width']);
		//$image_height = empty($instance['image_height']) ? '160' : apply_filters('widget_image_height', $instance['image_height']);
		//$image_cut = empty($instance['image_cut']) ? '' : apply_filters('widget_image_cut', $instance['image_cut']);
		?>
  
  <div class="page_title"><h3><?php echo $title;?> </h3>
  <?php if($link_url) {?>
	  <div class="sticky-link">
	    <div class="link-holder">
	  		<a href="<?php echo site_url()."/".$link_url; ?>">View all</a>
	  	</div>
	  </div>
   <?php  } ?>   
  </div>
  
   
  
  
  <?php
if(have_posts())
{
	$limit = $display_prds_no;
	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
	if($category)
	{
		$blogCategoryIdStr =$category;	
	}else
	{
		$blogCategoryIdStr = str_replace(',',',-',get_inc_categories("cat_exclude_"));	
	}
	query_posts('showposts=' . $limit . '&paged=' . $paged .'&cat='.$blogCategoryIdStr);
?>
  <ul style="display: block;" class="display <?php if($list_type=='Grid'){echo 'thumb_view';}?> ">
    <?php
    while(have_posts())
    {
        the_post();
		$post->image_width = $image_width;
		$post->image_height = $image_height;
		$Product->product_listing_li($post,array('image_cut'=>$image_cut));
    }
	?>
  </ul>
  

  
  
  <?php
}
?>
  
  
  <?php
		echo $after_widget;
	}

	function update($new_instance, $old_instance) {
	//save the widget
		$instance = $old_instance;
		$instance['category'] = strip_tags($new_instance['category']);
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['display_prds_no'] = strip_tags($new_instance['display_prds_no']);
		$instance['list_type'] = strip_tags($new_instance['list_type']);
		$instance['show_store_link'] = strip_tags($new_instance['show_store_link']);
		$instance['link_url'] = strip_tags($new_instance['link_url']);
		//$instance['image_width'] = strip_tags($new_instance['image_width']);
		//$instance['image_height'] = strip_tags($new_instance['image_height']);
		//$instance['image_cut'] = strip_tags($new_instance['image_cut']);
		return $instance;
	}

	function form($instance) {
	//widgetform in backend	
		$instance = wp_parse_args( (array) $instance, array( 'title' => 'Latest Products','display_prds_no' => '10','list_type' => 'Grid' ,'show_store_link' => '1') );
		$category = strip_tags($instance['category']);
		$title = strip_tags($instance['title']);
		$display_prds_no = strip_tags($instance['display_prds_no']);
		$list_type = strip_tags($instance['list_type']);
		$show_store_link = strip_tags($instance['show_store_link']);
		$link_url = strip_tags($instance['link_url']);
		//$image_width = strip_tags($instance['image_width']);
		//$image_height = strip_tags($instance['image_height']);		
		//$image_cut = strip_tags($instance['image_cut']);		
?>
<p>
  <label for="<?php echo $this->get_field_id('category'); ?>"><?php _e('Categories (<code>IDs</code> separated by commas):');?>
  <input class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>" type="text" value="<?php echo attribute_escape($category); ?>" />
  </label>
</p>
<p>
  <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title');?> :</label>
  <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" />
</p>
<p>  <label for="<?php echo $this->get_field_id('display_prds_no'); ?>"><?php _e('Number of Products');?> :</label>
  <input class="widefat" id="<?php echo $this->get_field_id('display_prds_no'); ?>" name="<?php echo $this->get_field_name('display_prds_no'); ?>" type="text" value="<?php echo attribute_escape($display_prds_no); ?>" /></p>
<p>  <label for="<?php echo $this->get_field_id('list_type'); ?>"><?php _e('Listing Type');?> :  </label>
  <select name="<?php echo $this->get_field_name('list_type'); ?>" id="<?php echo $this->get_field_id('list_type'); ?>" style="width:50%;">
  <option <?php if(attribute_escape($list_type)=='Grid'){ echo 'selected="selected"';} ?> >Grid</option>
  <option <?php if(attribute_escape($list_type)=='List'){ echo 'selected="selected"';} ?>>List</option>
  </select>
  </label>
</p>
<p>  
<label for="<?php echo $this->get_field_id('show_store_link'); ?>">
<input class="" id="<?php echo $this->get_field_id('show_store_link'); ?>" value="1" name="<?php echo $this->get_field_name('show_store_link'); ?>" type="checkbox" <?php if(attribute_escape($show_store_link)){ echo 'checked="checked"';} ?>  />
<?php _e('Wish to display Store link?');?></label>
</p>
<p>
  <label for="<?php echo $this->get_field_id('link_url'); ?>"><?php _e('View all link');?> :</label>
  <input class="widefat" id="<?php echo $this->get_field_id('link_url'); ?>" name="<?php echo $this->get_field_name('link_url'); ?>" type="text" value="<?php echo attribute_escape($link_url); ?>" />
</p>
<?php /*?><p>
  <label for="<?php echo $this->get_field_id('image_width'); ?>"><?php _e('Image Width (in px)');?> :</label>
  <input class="widefat" id="<?php echo $this->get_field_id('image_width'); ?>" name="<?php echo $this->get_field_name('image_width'); ?>" type="text" value="<?php echo attribute_escape($image_width); ?>" />
</p><?php */?>
<?php /*?><p>
  <label for="<?php echo $this->get_field_id('image_height'); ?>"><?php _e('Image Height (in px)');?> :</label>
  <input class="widefat" id="<?php echo $this->get_field_id('image_height'); ?>" name="<?php echo $this->get_field_name('image_height'); ?>" type="text" value="<?php echo attribute_escape($image_height); ?>" />
</p><?php */?>
<?php /*?><p>  <label for="<?php echo $this->get_field_id('image_cut'); ?>"><?php _e('Image Cutting Type');?> :  </label>
  <select name="<?php echo $this->get_field_name('image_cut'); ?>" id="<?php echo $this->get_field_id('image_cut'); ?>" style="width:50%;">
  <option <?php if(attribute_escape($image_cut)=='center'){ echo 'selected="selected"';} ?> >center</option>
  <option <?php if(attribute_escape($image_cut)=='top'){ echo 'selected="selected"';} ?>>top</option>
  <option <?php if(attribute_escape($image_cut)=='bottom'){ echo 'selected="selected"';} ?>>bottom</option>
  <option <?php if(attribute_escape($image_cut)=='left'){ echo 'selected="selected"';} ?>>left</option>
  <option <?php if(attribute_escape($image_cut)=='right'){ echo 'selected="selected"';} ?>>right</option>
  <option <?php if(attribute_escape($image_cut)=='top right'){ echo 'selected="selected"';} ?>>top right</option>
  <option <?php if(attribute_escape($image_cut)=='top left'){ echo 'selected="selected"';} ?>>top left</option>
  <option <?php if(attribute_escape($image_cut)=='bottom right'){ echo 'selected="selected"';} ?>>bottom right</option>
  <option <?php if(attribute_escape($image_cut)=='bottom left'){ echo 'selected="selected"';} ?>>bottom left</option>
  </select>
  </label>
</p><?php */?>
<?php
	}

}
register_widget('latest_product_navi_widget');


// =============================== Connect with us ======================================
class socialmediaWidget extends WP_Widget {
	function socialmediaWidget() {
	//Constructor
		$widget_ops = array('classname' => 'widget Connect with us', 'description' => 'connect with us widget' );		
		$this->WP_Widget('widget_socialmediaWidget', 'PT &rarr; Connect with us', $widget_ops);
	}
	function widget($args, $instance) {
	// prints the widget
		extract($args, EXTR_SKIP);
		$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
		$text = empty($instance['text']) ? '' : apply_filters('widget_text', $instance['text']);
		$twitter = empty($instance['twitter']) ? '' : apply_filters('widget_twitter', $instance['twitter']);
		$facebook = empty($instance['facebook']) ? '' : apply_filters('widget_facebook', $instance['facebook']);
		$rss = empty($instance['rss']) ? '' : apply_filters('widget_rss', $instance['rss']);
		 ?>						

 
      
      <div class="connect">
            <?php if ( $text <> "" ) { ?><p><?php echo $text; ?></p><?php } ?>
            <?php if ( $title <> "" ) { ?><h3><?php echo $title; ?></h3><?php } ?>
           	<div class="icons">
			<?php if ( $twitter <> "" ) { ?> <a href="<?php echo $twitter; ?>" class="i_twitter" ></a><?php } ?>
            <?php if ( $facebook <> "" ) { ?><a href="<?php echo $facebook; ?>" class="i_facebook"></a><?php } ?>
            <?php if ( $rss <> "" ) { ?><a href="<?php echo $rss; ?>" class="i_rss" ></a><?php } ?>
            </div>
        </div>
      
              
	<?php
	}
	function update($new_instance, $old_instance) {
	//save the widget
		$instance = $old_instance;		
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['text'] = ($new_instance['text']);
		$instance['twitter'] = ($new_instance['twitter']);
		$instance['facebook'] = ($new_instance['facebook']);
		$instance['rss'] = ($new_instance['rss']);
		return $instance;
	}
	function form($instance) {
	//widgetform in backend
		$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );		
		$title = strip_tags($instance['title']);
		$text = ($instance['text']);
		$twitter = ($instance['twitter']);
		$facebook = ($instance['facebook']);
		$rss = ($instance['rss']);			
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>">Widget Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>

<p><label for="<?php echo $this->get_field_id('text'); ?>">Text: <input class="widefat" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>" type="text" value="<?php echo attribute_escape($text); ?>" /></label></p>

<p><label for="<?php echo $this->get_field_id('twitter'); ?>">Twitter Full URL (ex.http://twitter.com/templatic) <input class="widefat" id="<?php echo $this->get_field_id('twitter'); ?>" name="<?php echo $this->get_field_name('twitter'); ?>" type="text" value="<?php echo attribute_escape($twitter); ?>" /></label></p>

<p><label for="<?php echo $this->get_field_id('facebook'); ?>">Facebook Full URL <input class="widefat" id="<?php echo $this->get_field_id('facebook'); ?>" name="<?php echo $this->get_field_name('facebook'); ?>" type="text" value="<?php echo attribute_escape($facebook); ?>" /></label></p>

<p><label for="<?php echo $this->get_field_id('rss'); ?>">RSS Full URL <input class="widefat" id="<?php echo $this->get_field_id('rss'); ?>" name="<?php echo $this->get_field_name('rss'); ?>" type="text" value="<?php echo attribute_escape($rss); ?>" /></label></p>

 
<?php
	}}
register_widget('socialmediaWidget');


// =============================== Social Media ======================================
class sociallink extends WP_Widget {
	function sociallink() {
	//Constructor
		$widget_ops = array('classname' => 'widget Social Media', 'description' => 'social Media widget' );		
		$this->WP_Widget('widget_sociallink', 'PT &rarr; Social Media', $widget_ops);
	}
	function widget($args, $instance) {
	// prints the widget
		extract($args, EXTR_SKIP);
		$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
		$youtube = empty($instance['youtube']) ? '' : apply_filters('widget_youtube', $instance['youtube']);
		$twitter = empty($instance['twitter']) ? '' : apply_filters('widget_twitter', $instance['twitter']);
		$facebook = empty($instance['facebook']) ? '' : apply_filters('widget_facebook', $instance['facebook']);
		$rss = empty($instance['rss']) ? '' : apply_filters('widget_rss', $instance['rss']);
		 ?>				
         
         <?php if ( $title <> "" ) { ?><h3><?php echo $title; ?></h3><?php } ?>		

            <ul class="social">
                <?php if ( $facebook <> "" ) { ?><li><a href="<?php echo $facebook; ?>" title="Facebook" class="facebook">Facebook</a></li><?php } ?>
                <?php if ( $youtube <> "" ) { ?><li><a href="<?php echo $youtube; ?>" title="Youtube" class="youtube">Youtube</a></li><?php } ?>
                <?php if ( $rss <> "" ) { ?><li><a href="<?php echo $rss; ?>" title="RSS Feeds" class="rss">RSS Feeds</a></li><?php } ?>
                <?php if ( $twitter <> "" ) { ?> <li><a href="<?php echo $twitter; ?>" title="Twitter" class="twitter">Twitter</a></li><?php } ?>
            </ul>  
      
              
	<?php
	}
	function update($new_instance, $old_instance) {
	//save the widget
		$instance = $old_instance;		
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['youtube'] = ($new_instance['youtube']);
		$instance['twitter'] = ($new_instance['twitter']);
		$instance['facebook'] = ($new_instance['facebook']);
		$instance['rss'] = ($new_instance['rss']);
		return $instance;
	}
	function form($instance) {
	//widgetform in backend
		$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );		
		$title = strip_tags($instance['title']);
		$youtube = ($instance['youtube']);
		$twitter = ($instance['twitter']);
		$facebook = ($instance['facebook']);
		$rss = ($instance['rss']);			
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>">Widget Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>

<p><label for="<?php echo $this->get_field_id('twitter'); ?>">Twitter Full URL (ex.http://twitter.com/templatic) <input class="widefat" id="<?php echo $this->get_field_id('twitter'); ?>" name="<?php echo $this->get_field_name('twitter'); ?>" type="text" value="<?php echo attribute_escape($twitter); ?>" /></label></p>

<p><label for="<?php echo $this->get_field_id('facebook'); ?>">Facebook Full URL <input class="widefat" id="<?php echo $this->get_field_id('facebook'); ?>" name="<?php echo $this->get_field_name('facebook'); ?>" type="text" value="<?php echo attribute_escape($facebook); ?>" /></label></p>

<p><label for="<?php echo $this->get_field_id('rss'); ?>">RSS Full URL <input class="widefat" id="<?php echo $this->get_field_id('rss'); ?>" name="<?php echo $this->get_field_name('rss'); ?>" type="text" value="<?php echo attribute_escape($rss); ?>" /></label></p>

<p><label for="<?php echo $this->get_field_id('youtube'); ?>">Youtube Full URL : <input class="widefat" id="<?php echo $this->get_field_id('youtube'); ?>" name="<?php echo $this->get_field_name('youtube'); ?>" type="text" value="<?php echo attribute_escape($youtube); ?>" /></label></p>


 
<?php
	}}
register_widget('sociallink');
 
?>